package org.example.leetcpde;

import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Array;
import java.util.Arrays;

public class reverse {

    private static final Logger log = LoggerFactory.getLogger(reverse.class);

    @Test
    void reverse() {

        long reverse = reverse(1534236469);
        System.out.println(reverse);
    }

    public int reverse(int x) {
        long res = 0;
        do {
            res = res * 10 + x % 10;
            if (res > Integer.MAX_VALUE || res < Integer.MIN_VALUE) {
                return 0;
            }
        } while ((x /= 10) != 0);

        return Long.valueOf(res).intValue();
    }
}
